import { Game, GameComponent } from "@sapi-game/main";
import { Duration } from "@sapi-game/utils";
import { EffectIds } from "@sapi-game/utils/vanila-data";
import { KcpdBackState } from "./kcpdBack";

export class KcpdWatingRoom extends GameComponent<KcpdBackState> {
    override onAttach(): void {
        this.subscribe(
            Game.events.interval,
            () => {
                const players = this.state.region.getPlayersInRegion();
                players.forEach((p) => {
                    if (!p.isValid) return;
                    p.onScreenDisplay.setActionBar(
                        "§6烤肠派对玩家§r:" + this.state.players.validSize
                    );
                    //给效果
                    p.addEffect(EffectIds.Resistance, 70, {
                        amplifier: 10,
                        showParticles: false,
                    });
                    p.addEffect(EffectIds.Regeneration, 70, {
                        amplifier: 100,
                        showParticles: false,
                    });
                });
            },
            new Duration(20)
        );
    }
}
